#pragma once

#include <cmath>
#include <cstdlib>

namespace MISRENDER
{
	template <typename T> T interpolateLinear(T v0, T v1, float x)
	{
		return v0 + (v1-v0) * x;
	}
  
	template <typename T> T interpolateCosine(T y1, T y2, float mu)
	{
    double mu2 = (1-cos(mu*3.1415927f))/2.0f;
    return T(y1 * (1.0f - mu2 ) + y2 * mu2 );
	}

	template <typename T> T interpolateCubic(T v0, T v1, T v2, T v3, float x)
	{
		T P = (v3-v2) - (v0 - v1);
		T Q = (v0-v1) - P;
		T R = v2-v0;
		T S = v1;
		return P*x*x*x + Q*x*x + R*x + S;
	}

 	__inline float frand()
	{
		return (float(rand()) / float(RAND_MAX) * 2.0f) - 1.0f;
	}

} // end namespace MISRENDER
